<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title><c:if test="${student.id != null}">修改</c:if><c:if test="${student.id == null}">新增</c:if>学生</title>
    <style>
        form {
            width: 400px;
            margin: 0 auto;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        input, textarea {
            width: 100%;
            padding: 8px;
            margin-bottom: 15px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <h1><c:if test="${student.id != null}">修改</c:if><c:if test="${student.id == null}">新增</c:if>学生</h1>
    <form action="${pageContext.request.contextPath}/student/save" method="post">
        <input type="hidden" name="id" value="${student.id}">
        
        <label>姓名:</label>
        <input type="text" name="name" value="${student.name}" required>
        
        <label>出生日期:</label>
        <input type="date" name="birthdayStr" 
               value="<c:if test="${student.birthday != null}"><fmt:formatDate value="${student.birthday}" pattern="yyyy-MM-dd"/></c:if>" 
               required>
        
        <label>备注:</label>
        <textarea name="description" rows="4">${student.description}</textarea>
        
        <label>平均分:</label>
        <input type="number" name="avgscore" value="${student.avgscore}" required>
        
        <button type="submit">保存</button>
    </form>
    <a href="${pageContext.request.contextPath}/student/list">返回列表</a>
</body>
</html>    